home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Misc / emu / p-interp.lha / p-interp-0.5 / float-conv.c < prev    next >
C/C++ Source or Header  |  2001-05-20  |  1KB  |  51 lines

  1. /*
  2.  
  3.   P-Code interpreter (to run the apple pascal system)
  4.   Copyright (C) 2000 Mario Klebsch
  5.  
  6.   This program is free software; you can redistribute it and/or modify
  7.   it under the terms of the GNU General Public License as published by
  8.   the Free Software Foundation; either version 2 of the License, or
  9.   (at your option) any later version.
  10.  
  11.   This program is distributed in the hope that it will be useful,
  12.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.   GNU General Public License for more details.
  15.  
  16.   You should have received a copy of the GNU General Public License
  17.   along with this program; if not, write to the Free Software
  18.   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20.  
  21.   $Log: float-conv.c,v $
  22.   Revision 1.2  2001/05/20 13:12:02  mario
  23.   CVS-Idents und Logs eingefügt
  24.  
  25.  
  26. */
  27.  
  28. #ident "$Id: float-conv.c,v 1.2 2001/05/20 13:12:02 mario Exp $";
  29.  
  30. #include <stdio.h>
  31.  
  32. int main(int argc, char *argv[])
  33. {
  34.   char    Buffer[256];
  35.   while (fgets(Buffer, sizeof(Buffer), stdin))
  36.     {
  37.       float        fl;
  38.       unsigned char    *p=(unsigned char*)&fl;
  39.       unsigned short    *us=(unsigned short*)&fl;
  40.       int        i;
  41.  
  42.       sscanf(Buffer, "%f", &fl);
  43.       for (i=0;i<sizeof(fl);i++)
  44.     printf("%02x ", p[i]);
  45.       printf("\n");
  46.       for (i=0;i<sizeof(fl)/sizeof(us[0]);i++)
  47.     printf("%04x ", us[i]);
  48.       printf("\n");
  49.     }
  50. }
  51.